{
  "name": "Case 5 – B2B Sales Lead Qualification & Deal Prioritization",
  "nodes": [
    {
      "name": "On form submission",
      "type": "n8n-nodes-base.formTrigger",
      "typeVersion": 2,
      "position": [0, 0],
      "parameters": {
        "formTitle": "B2B Sales Lead Submission",
        "formDescription": "Submit lead details for sales qualification",
        "formFields": {
          "values": [
            { "fieldLabel": "Lead Name", "requiredField": true },
            { "fieldLabel": "Contact Email", "fieldType": "email", "requiredField": true },
            {
              "fieldLabel": "Lead_Brief",
              "fieldType": "file",
              "acceptFileTypes": ".pdf",
              "requiredField": true
            }
          ]
        }
      }
    },
    {
      "name": "Upload file",
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [220, 0],
      "parameters": {
        "inputDataFieldName": "Lead_Brief",
        "name": "={{ $json['Lead Name'] + '_Lead_Brief' }}",
        "folderId": "REPLACE_WITH_SALES_FOLDER_ID"
      }
    },
    {
      "name": "Download file",
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [420, 0],
      "parameters": {
        "operation": "download",
        "fileId": "={{ $json.id }}"
      }
    },
    {
      "name": "Extract Lead Brief",
      "type": "n8n-nodes-base.extractFromFile",
      "typeVersion": 1,
      "position": [620, 0],
      "parameters": { "operation": "pdf" }
    },
    {
      "name": "Download Sales Policy",
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [820, 0],
      "parameters": {
        "operation": "download",
        "fileId": "REPLACE_WITH_SALES_POLICY_FILE_ID"
      }
    },
    {
      "name": "Extract Sales Policy",
      "type": "n8n-nodes-base.extractFromFile",
      "typeVersion": 1,
      "position": [1020, 0],
      "parameters": { "operation": "pdf" }
    },
    {
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 3,
      "position": [220, 260],
      "parameters": {
        "promptType": "define",
        "text": "=Lead Brief:\n{{ $('Extract Lead Brief').item.json.text }}\n\nSales Qualification Policy:\n{{ $('Extract Sales Policy').item.json.text }}",
        "options": {
          "systemMessage": "You are a Senior Revenue Operations Manager. Qualify and prioritize the sales lead strictly as per policy. Output ONLY valid JSON and call the Google Sheets Append Row tool."
        }
      }
    },
    {
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1,
      "position": [0, 420],
      "parameters": {
        "model": { "mode": "list", "value": "gpt-4.1-mini" }
      }
    },
    {
      "name": "Append row",
      "type": "n8n-nodes-base.googleSheetsTool",
      "typeVersion": 4,
      "position": [420, 460],
      "parameters": {
        "operation": "append",
        "documentId": "REPLACE_WITH_GOOGLE_SHEET_ID",
        "sheetName": "Sales Lead Qualification & Deal Priority Register"
      }
    },
    {
      "name": "Send Email",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2,
      "position": [420, 260],
      "parameters": {
        "sendTo": "={{ $('On form submission').item.json['Contact Email'] }}",
        "subject": "Sales Lead Review – Initial Assessment",
        "message": "={{ 'Dear Team,<br><br>The submitted sales lead has been reviewed and prioritized based on our qualification framework. The assigned sales owner will take the next steps accordingly.<br><br>Regards,<br>Revenue Operations' }}"
      }
    }
  ],
  "connections": {
    "On form submission": { "main": [[{ "node": "Upload file" }]] },
    "Upload file": { "main": [[{ "node": "Download file" }]] },
    "Download file": { "main": [[{ "node": "Extract Lead Brief" }]] },
    "Extract Lead Brief": { "main": [[{ "node": "Download Sales Policy" }]] },
    "Download Sales Policy": { "main": [[{ "node": "Extract Sales Policy" }]] },
    "Extract Sales Policy": { "main": [[{ "node": "AI Agent" }]] },
    "OpenAI Chat Model": { "ai_languageModel": [[{ "node": "AI Agent" }]] },
    "Append row": { "ai_tool": [[{ "node": "AI Agent" }]] },
    "AI Agent": { "main": [[{ "node": "Send Email" }]] }
  },
  "active": false
}
